<form class="form-inline" method="get">

    <div class="form-group col-xs-2">
        <div class="col-xs-12">
            <input class="form-control" name="id" value="{$id}"
                   placeholder="公告ID">
        </div>
    </div>

    <div class="form-group col-xs-2">
        <div class="col-xs-12">
            <input class="form-control" name="condition" value="{$condition}"
                   placeholder="公告标题">
        </div>
    </div>

    <div class="form-group col-xs-2">
        <select id="is-visible-selector" name="is_visible" class="form-control" tabindex="-1">
            <option value="">
                无选择
            </option>
            <option value="1" {if condition="$is_visible != '' && $is_visible==1"}selected{/if} >显示</option>
            <option value="0" {if condition="$is_visible != '' && $is_visible==0"}selected{/if} >隐藏</option>
        </select>
    </div>

    <div class="form-group col-xs-2">
        <button type="submit" class="btn btn-success">
            搜索
        </button>

        <button type="button" class="btn btn-primary" onclick="modal('{:url(\'add\')}','添加公告')">
            添加公告
        </button>
    </div>
</form>

<hr>

<table class="table table-striped">
    <thead>
    <tr>
        <td>ID</td>
        <td>标题</td>
        <td>排序</td>
        <td>是否显示</td>
        <td>时间</td>
        <td>操作</td>
    </tr>
    </thead>
    <tbody>
    {volist name="list" id="item"}
    <tr>
        <td>{$item.id}</td>
        <td>{$item.title}</td>
        <td>{$item.display_order}</td>
        <td>
            {if $item["is_visible"]}
            <label class="label label-success" data-toggle="ajaxSwitch" data-switch-status="1"
                   data-switch-value-0="1|显示|label label-success|{:url('Notice/visible',array('id'=>$item['id'],'status'=>1))}"
                   data-switch-value-1="0|隐藏|label label-danger|{:url('Notice/visible',array('id'=>$item['id'],'status'=>0))}">显示</label>
            {else}
            <label class="label label-danger" data-toggle="ajaxSwitch" data-switch-status="0"
                   data-switch-value-0="1|显示|label label-success|{:url('Notice/visible',array('id'=>$item['id'],'status'=>1))}"
                   data-switch-value-1="0|隐藏|label label-danger|{:url('Notice/visible',array('id'=>$item['id'],'status'=>0))}">隐藏</label>
            {/if}
        </td>

        <td>
            <p>创建时间：{$item.create_time|show_datetime}</p>
            <p>编辑时间：{$item.update_time|show_datetime}</p>
        </td>
        <td>

            <a href="javascript:void(0)" class="btn btn-primary btn-sm"
               onclick="modal('{:url(\'edit\',array(\'id\'=>$item[\'id\']))}','编辑通知')">编辑</a>
            <a href="javascript:void(0)" class="btn btn-danger btn-sm" data-toggle="confirm" data-title="删除"
               data-content="确定要删除吗？删除后不可恢复"
               data-url="{:url('remove',array('id'=>$item['id']))}">删除</a>

        </td>
    </tr>
    {/volist}
    </tbody>
</table>

<div class="row">
    <div class="col-xs-12" style="text-align: right;">
        {$list->render()}
    </div>
</div>

<script src="__PUBLIC__/vendors/select2/js/select2.min.js"></script>
<script type="application/javascript">
    $(function () {
        $("#is-visible-selector").select2({
            placeholder: "选择是否显示",
            allowClear: true
        });
    });
</script>
